<?php
include 'db.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $name = $_POST['name'];
    $description = $_POST['description'];
    $price = $_POST['price'];
    $status = $_POST['status'];
    $log_enabled = $_POST['log_enabled'];

    $stmt = $pdo->prepare("INSERT INTO tools (name, description, price, status, log_enabled) VALUES (?, ?, ?, ?, ?)");
    $stmt->execute([$name, $description, $price, $status, $log_enabled]);

    echo json_encode(['success' => true, 'message' => '小工具新增成功']);
} else {
    echo json_encode(['success' => false, 'message' => 'Invalid request method']);
}